import React, { Component } from 'react';
import { Router, Route, IndexRoute } from 'react-router';
import App from 'common/containers/App.js';
import Error from 'common/containers/Error.js';
import Main from '../main/index.js';

import SysUser from '../sys/sysUser/index.js';
import SysRole from '../sys/sysRole/index.js';

import SysLog from '../log/sysLog/index.js';
import LoginLog from '../log/loginLog/index.js';

import ShopClassify from '../shop/shopClassify/index.js';
import ShopGoods from '../shop/shopGoods/index.js';
import ShopOrder from '../shop/shopOrder/index.js';

import UserInfo from '../user/userInfo/index.js';

/**
 * 路由
 */
class RouteMap extends Component{

	onUpdate = () => {
		window.scrollTo(0,0);
	}

	render(){
		return(
			<Router history={this.props.history} onUpdate={this.onUpdate}>
				<Route path="/" component={App}>
					<IndexRoute component={Main} title="主页" />
					
					<Route path="/sysUser" component={SysUser}/>
					<Route path="/sysRole" component={SysRole}/>
					
					<Route path="/sysLog" component={SysLog}/>
					<Route path="/loginLog" component={LoginLog}/>
					
					<Route path="/shopClassify" component={ShopClassify}/>
					<Route path="/shopGoods" component={ShopGoods}/>
					<Route path="/shopOrder" component={ShopOrder}/>
					
					<Route path="/userInfo" component={UserInfo}/>
					
					<Route path="*" component={Error}/>
				</Route>
			</Router>
		)
	}
}

export default RouteMap;